var isOpen = 1;
var interval;
$(function() {
	$("#content").hide();
	$("#toFindSessionBtn").click(function() {
		$("#content").show();
	});

	$("#openfind").click(function() {
		if(isOpen == 1) {
			isOpen = 2;
			interval = window.setInterval(function() {
				$.ajax({
					url: path + "/manager/cleanSession.do",
					dataType: "json",
					async: false,
					type: "POST",
					beforeSend: function() {
						//请求前的处理
					},
					success: function(datas) {
						console.log(111);
						if(datas.length>0) {
							var myDate = new Date();
							var year = myDate.getFullYear(); //获取完整的年份
							var month = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
							var day = myDate.getDate(); //获取当前日(1-31)
							var hours = myDate.getHours(); //获取当前小时数(0-23)
							var minutes = myDate.getMinutes(); //获取当前分钟数(0-59)
							var seconds = myDate.getSeconds(); //获取当前秒数(0-59)
							var date = year + month + day + hours + minutes + seconds;
							$("#nomsg").hide();
							$.each(datas, function(i, data) {
								var html = "<tr><td>" + data.blockedSqlId + "</td>";
								html += "<td>" + data.blockInfo + "</td>";
								html += "<td>" + data.module + "</td>";
								html += "<td>" + data.blockedModule + "</td>";
								html += "<td>" + data.blockedDataQuerysql + "</td></tr>";
								$("#blockInfoTab").append(html);
								var optionHtml = "<option>"+date+"\t"+data.blockInfo+"</option>";
								$("#killSessionSel").append(optionHtml);
							});
							
						}
					},
					complete: function() {
						//请求完成的处理
					},
					error: function() {
						//请求出错处理
					}
				});
			}, 3000);
		} else {
			isOpen = 1;
			clearInterval(interval);
		}
	});
});